// Need to use the React-specific entry point to import createApi
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
import { HttpResponse, WallpaperTypeListParams } from '@interfaces';
import { baseURL } from '@config';
import { serialize } from '@helpers';
const prefix = `/api/`;

// Define a service using a base URL and expected endpoints
export const wallpaperTypeApi = createApi({
  reducerPath: 'wallpapertype',
  baseQuery: fetchBaseQuery({ baseUrl: `${baseURL}${prefix}` }),
  endpoints: (builder) => ({
    getWallpaperTypes: builder.query<HttpResponse, WallpaperTypeListParams>({
      query: params => `wallpapertype${serialize(params)}`,
    }),
  }),
})

// Export hooks for usage in functional components, which are
// auto-generated based on the defined endpoints
export const { useGetWallpaperTypesQuery } = wallpaperTypeApi
